    // 迁徙图数据及配置ss
    var geoCoordMap = {
        '珠海市': [113.576823, 22.271627],
        '广州市': [113.5107, 23.2196],
        '中山市': [113.4229, 22.478],
        '江门市': [112.6318, 22.1484],
        '佛山市': [113.117089, 23.029334],
        '肇庆市': [112.1265, 23.5822],
        '惠州市': [114.410386, 23.078431],
        '阳江市': [111.982626, 21.857386],
        '航展馆': [113.377592, 22.010884],
        '香洲公交总站': [113.567355, 22.279396],
        '体育中心东门': [113.540013, 22.274001],
        '九洲城': [113.579649, 22.257129],
        '九洲港': [113.59224, 22.239854],
        '城轨珠海站': [113.551067, 22.216261],
        '前山枢纽站': [113.526656, 22.232829],
        '华发商都': [113.511513, 22.224122],
        '斗门汽车客运站': [113.308472, 22.228153],
        '珠海国际赛车场停车场': [113.566641, 22.365226],
        '广州东站汽车客运站': [113.322422, 23.153136],
        '广州海珠汽车客运站': [113.299044, 23.063453],
        '广州滘口汽车客运站': [113.208201, 23.114174],
        '广州南汽车客运站': [113.271321, 22.992267],
        '广州汽车客运站': [113.252165, 23.14723],
        '广州省汽车客运站': [113.252514, 23.148142],
        '中山市城东车站': [113.465773, 22.560174],
        '中山市小榄汽车客运站': [113.25887, 22.671994],
        '中山汽车客运站': [113.342324, 22.521008],
        '江门汽车总站': [113.067184, 22.631277],
        '开平汽车总站': [112.690057, 22.365909],
        '佛山汽车客运站': [113.110523, 23.041573],
        '三水汽车客运站': [112.879596, 23.17888],
        '均安汽车客运站': [113.150454, 22.714338],
        '勒流汽车客运站': [113.131567, 22.855733],
        '顺德汽车客运站': [113.250833, 22.818035],
        '肇庆市汽车客运站': [112.474351, 23.055533],
        '惠州汽车客运站': [114.461263, 22.814371],
        '阳江二运汽车客运站': [111.970363, 21.882358],
        '阳江汽车客运站': [111.962593, 21.881702],
        '阳春汽车客运站': [111.791199, 22.163946],
        '阳西汽车客运站': [111.612895, 21.767822]
    };

    var CSData = {
        '珠海市':[{name: '航展馆'}, {name: '珠海市', car: 0, num: 0}],
        '广州市':[{name: '航展馆'}, {name: '广州市', car: 0, num: 0}],
        '中山市':[{name: '航展馆'}, {name: '中山市', car: 0, num: 0}],
        '江门市':[{name: '航展馆'}, {name: '江门市', car: 0, num: 0}],
        '佛山市':[{name: '航展馆'}, {name: '佛山市', car: 0, num: 0}],
        '肇庆市':[{name: '航展馆'}, {name: '肇庆市', car: 0, num: 0}],
        '惠州市':[{name: '航展馆'}, {name: '惠州市', car: 0, num: 0}],
        '阳江市':[{name: '航展馆'}, {name: '阳江市', car: 0, num: 0}],
    };
    var CCDData = {
        '香洲公交总站': [{name: '航展馆'}, {name: '香洲公交总站', car: 0, num: 0}],
        '体育中心东门': [{name: '航展馆'}, {name: '体育中心东门', car: 0, num: 0}],
        '九洲城': [{name: '航展馆'}, {name: '九洲城', car: 0, num: 0}],
        '九洲港': [{name: '航展馆'}, {name: '九洲港', car: 0, num: 0}],
        '城轨珠海站':[{name: '航展馆'}, {name: '城轨珠海站', car: 0, num: 0}],
        '前山枢纽站':[{name: '航展馆'}, {name: '前山枢纽站', car: 0, num: 0}],
        '华发商都':[{name: '航展馆'}, {name: '华发商都', car: 0, num: 0}],
        '斗门汽车客运站':[{name: '航展馆'}, {name: '斗门汽车客运站', car: 0, num: 0}],
        '珠海国际赛车场停车场':[{name: '航展馆'}, {name: '珠海国际赛车场停车场', car: 0, num: 0}],
        '广州东站汽车客运站':[{name: '航展馆'}, {name: '广州东站汽车客运站', car: 0, num: 0}],
        '广州海珠汽车客运站':[{name: '航展馆'}, {name: '广州海珠汽车客运站', car: 0, num: 0}],
        '广州滘口汽车客运站':[{name: '航展馆'}, {name: '广州滘口汽车客运站', car: 0, num: 0}],
        '广州南汽车客运站':[{name: '航展馆'}, {name: '广州南汽车客运站', car: 0, num: 0}],
        '广州汽车客运站':[{name: '航展馆'}, {name: '广州汽车客运站', car: 0, num: 0}],
        '广州省汽车客运站':[{name: '航展馆'}, {name: '广州省汽车客运站', car: 0, num: 0}],
        '中山市城东车站':[{name: '航展馆'}, {name: '中山市城东车站', car: 0, num: 0}],
        '中山市小榄汽车客运站':[{name: '航展馆'}, {name: '中山市小榄汽车客运站', car: 0, num: 0}],
        '中山汽车客运站':[{name: '航展馆'}, {name: '中山汽车客运站', car: 0, num: 0}],
        '江门汽车总站':[{name: '航展馆'}, {name: '江门汽车总站', car: 0, num: 0}],
        '开平汽车总站':[{name: '航展馆'}, {name: '开平汽车总站', car: 0, num: 0}],
        '佛山汽车客运站':[{name: '航展馆'}, {name: '佛山汽车客运站', car: 0, num: 0}],
        '三水汽车客运站':[{name: '航展馆'}, {name: '三水汽车客运站', car: 0, num: 0}],
        '均安汽车客运站':[{name: '航展馆'}, {name: '均安汽车客运站', car: 0, num: 0}],
        '勒流汽车客运站':[{name: '航展馆'}, {name: '勒流汽车客运站', car: 0, num: 0}],
        '顺德汽车客运站':[{name: '航展馆'}, {name: '顺德汽车客运站', car: 0, num: 0}],
        '肇庆市汽车客运站':[{name: '航展馆'}, {name: '肇庆市汽车客运站', car: 0, num: 0}],
        '惠州汽车客运站':[{name: '航展馆'}, {name: '惠州汽车客运站', car: 0, num: 0}],
        '阳江二运汽车客运站':[{name: '航展馆'}, {name: '阳江二运汽车客运站', car: 0, num: 0}],
        '阳江汽车客运站':[{name: '航展馆'}, {name: '阳江汽车客运站', car: 0, num: 0}],
        '阳春汽车客运站':[{name: '航展馆'}, {name: '阳春汽车客运站', car: 0, num: 0}],
        '阳西汽车客运站':[{name: '航展馆'}, {name: '阳西汽车客运站', car: 0, num: 0}],
    };
    var ZHData = {
        '香洲公交总站':[{name: '航展馆'},{name: '香洲公交总站', car: 0, num: 0}],
        '体育中心东门':[{name: '航展馆'}, {name: '体育中心东门', car: 0, num: 0}],
        '九洲城':[{name: '航展馆'}, {name: '九洲城', car: 0, num: 0}],
        '九洲港':[{name: '航展馆'}, {name: '九洲港', car: 0, num: 0}],
        '城轨珠海站':[{name: '航展馆'}, {name: '城轨珠海站', car: 0, num: 0}],
        '前山枢纽站':[{name: '航展馆'}, {name: '前山枢纽站', car: 0, num: 0}],
        '华发商都':[{name: '航展馆'}, {name: '华发商都', car: 0, num: 0}],
        '斗门汽车客运站':[{name: '航展馆'}, {name: '斗门汽车客运站', car: 0, num: 0}],
        '珠海国际赛车场停车场':[{name: '航展馆'}, {name: '珠海国际赛车场停车场', car: 0, num: 0}]
    };
    var planePath = 'path://M515.308 77.115l508.692 866.462-515.256-249.436-508.744 252.744z';
    var convertData = function (data) {
        console.log(data);
        var res = [];
        for (var i in data) {
            var dataItem = data[i];
            var fromCoord = geoCoordMap[dataItem[1].name];
            var toCoord = geoCoordMap[dataItem[0].name];
            if (fromCoord && toCoord) {
                // res.push({
                //     fromName: dataItem[1].name,
                //     toName: dataItem[0].name,
                //     coords: [fromCoord, toCoord],
                //     car: dataItem[1].car,
                //     num: dataItem[1].num
                // });
                res[i]={
                    fromName: dataItem[1].name,
                    toName: dataItem[0].name,
                    coords: [fromCoord, toCoord],
                    car: dataItem[1].car,
                    num: dataItem[1].num
                };
            }
        }
        return res;
    };
    var color = [ '#46bee9','#fff799', '#81f663'];
    var series = [];
    // 迁徙图数据及配置ee
    var current_point_id = "";
    var current_move_id = 2;
    var airDispatch = {
        CheckChart:null,
        timer_car: null,
        timer_ride_point:null,
        timer_move:null,
        service: null,
        initServiceFlag:null,
        map: null,
        echartMap: null,
        markers: {},
        gps: null,
        worker:{},
        titles: {},
        contents: {},
        initView: function () {
            //水球图
            initCheckChart();
            // 默认只绘制车辆地图
            this.switchView1();
        },

        // 展示车辆地图
        switchView1: function () {
            clearTimer();
            airDispatch.service.clearBind();
            if(typeof airDispatch.map !== 'undefined' && airDispatch.map !==null ){
                console.log("destroyMap...")
                airDispatch.map.destroy();
                console.log(airDispatch.map);
                airDispatch.map = null;
            }
            if(this.echartMap != null){
                // 销毁echart实体
                this.echartMap.clear();
                this.echartMap.dispose();
                window.CollectGarbage && CollectGarbage();
                this.echartMap = null;
            }
            // 清空容器
            $("#container").empty();
            // 绘制地图
            airDispatch.map = initMap1();
            // 插入车辆
            airDispatch.service.init("getSpecialGps.do");
            $("#pointSelect").show();
            $(".center-map-mark").show();
            $("#pointSelect>span").html("市内乘车点");
            $("#moveSelect").hide();
            $("#workerSelect").show();
            // $("#workerSelect>span").html("隐藏工作人员");
            // changeWorkerMap("1");
        },

        // 展示迁徙图
        switchView2: function () {
            clearTimer();
            // 清空容器
            // $("#container").empty();
            if(typeof airDispatch.map !== 'undefined' && airDispatch.map !==null ){
                console.log("destroyMap...")
                airDispatch.map.destroy();
                console.log(airDispatch.map);
                airDispatch.map = null;
            }
            if(this.echartMap != null){
                // 销毁echart实体
                this.echartMap.clear();
                this.echartMap.dispose();
                window.CollectGarbage && CollectGarbage();
                this.echartMap = null;
            }
            // 清空容器
            $("#container").empty();
            // 插入迁徙图
            initEchartData();
            $("#pointSelect").hide();
            $(".center-map-mark").hide();
            $("#moveSelect").show();
            $("#moveSelect>span").html("市内乘车点");
            $("#workerSelect").hide();
        }
    };

    var clearTimer = function () {
        if (airDispatch.timer_car !== null) {
            window.clearInterval(airDispatch.timer_car);
        }
        if (airDispatch.timer_ride_point !== null) {
            window.clearInterval(airDispatch.timer_ride_point);
        }
        if (airDispatch.timer_move !== null) {
            window.clearInterval(airDispatch.timer_move);
        }
    };

    var initCheckChart = function () {
        airDispatch.CheckChart = echarts.init(document.getElementById('checkChart'));
        airDispatch.CheckChart.setOption(getCheckOption());
        setInterval(function () {
            airDispatch.CheckChart.setOption(getCheckOption());
        },1000*5);
    }

    var getCheckOption = function () {
        var check_show =0;
        $.ajax({
            type: "GET",
            url: "getTicketSum.do",
            success: function (result) {
                var checkedSum = result.data.checkedSum;
                var appointSum = result.data.appointSum;
                $("#checked-tickets").html(checkedSum);
                $("#appoint-tickets").html(appointSum);
                check_show = Math.round(checkedSum / appointSum * 10000) / 10000;
            }
        });
        checkOption = {
            series: [{
                color: [
                    'rgba(75,235,243,1)',
                    'rgba(8,205,245,.4)'
                ],
                type: 'liquidFill',
                amplitude: '4%',
                waveLength: '80%',
                radius: '80%',
                outline: {
                    borderDistance: 5,
                    itemStyle: {
                        borderWidth: 1,
                        borderColor: '#4cd3ff',
                        shadowBlur: 30,
                        shadowColor: '#fff'
                    }
                },
                backgroundStyle: {
                    color: '#0f5c89'
                },
                itemStyle: {
                    normal: {
                        shadowColor: 'rgba(17, 155, 227, 0.15)',
                        opacity: 0.8
                    }
                },
                label: {
                    normal: {
                        textStyle: {
                            color: 'rgba(255,255,255,0)',
                            insideColor: 'rgba(255,255,255,0)'
                        }
                    }
                },
                //todo  计算已检票人数占总票数的比重，数值0-1之间
                //todo  下面两个数字输入一样就好，纯视觉效果需要
                data: [ check_show , check_show ]
            }]
        };
        return checkOption;
    }

    // 初始化车辆地图
    var initMap1 = function () {
        //初始化地图
        var map = new AMap.Map('container', {
            resizeEnable: true, //是否监控地图容器尺寸变化
            // mapStyle: "amap://styles/macaron",
            mapStyle: "amap://styles/2bef887ede3762990229318b8d43fdd9", //自定义地图
            // center: [113.385252,22.217858],//中心点坐标
            center: [113.525686,22.208339],//中心点坐标
            zoom:11
        });
        //路况
        var trafficLayer = new AMap.TileLayer.Traffic({
            zIndex: 4,
            autoRefresh: true,     //是否自动刷新，默认为false
            interval: 180,         //刷新间隔，默认180s
            opacity: 0.9
        });
        trafficLayer.setMap(map);
        //珠海区
        var opts = {
            subdistrict: 1,   //返回下一级行政区
            showbiz: false  //最后一级返回街道信息
        };
        district = new AMap.DistrictSearch(opts);//注意：需要使用插件同步下发功能才能这样直接使用
        district.setLevel("city"); //行政区级别
        // district.setExtensions('all');
        district.search('440400', function (status, result) {
            if (status == 'complete') {
                getData(result.districtList[0], "city");
            }
        });

            function getData(data, level) {
                var bounds = data.boundaries;
                if (bounds) {
                    for (var i = 0, l = bounds.length; i < l; i++) {
                        var polygon = new AMap.Polygon({
                            map: map,
                            strokeWeight: 1,
                            strokeColor: '#0091ea',
                            fillColor: '#80d8ff',
                            fillOpacity: 0.2,
                            path: bounds[i]
                        });
                        // polygons.push(polygon);
                    }
                    map.setFitView();//地图自适应
                }
            }

            return map;
        };

    // 初始化迁徙图
    var initEchartData = function () {
        initMoveChartData();
        airDispatch.echartMap = echarts.init(document.getElementById('container'));
        // 默认加载全部乘车点迁徙图
        airDispatch.echartMap.setOption(getEchartOption(current_move_id));
        airDispatch.timer_move = setInterval(function () {
            initMoveChartData();
            airDispatch.echartMap.setOption(getEchartOption(current_move_id));
        },1000*60);
    };

    var initMoveChartData = function () {
        $.ajax({
            url:"getMoveChartData.do",
            type:"GET",
            async:false,
            success:function (data) {
                // todo CCDData,CSData,ZHData
                console.log(data);
                // var geoCoordList = data.data.geoCoordMap;
                // for(var l in geoCoordList){
                //     geoCoordMap[geoCoordList[l].key]=[geoCoordList[l].lon,geoCoordList[l].lat];
                // }
                var ZHDataList = data.data.ZHData;
                var CSDataList = data.data.CSData;
                var CCDDataList = data.data.CCDData;
                for(var z in ZHDataList){
                    var point = ZHDataList[z];
                    // ZHData.push([{name: '航展馆'}, {name: point.name, car: point.carSum, num: point.seatSum}]);
                    if(!geoCoordMap[point.name]) {
                        geoCoordMap[point.name] = [Number(point.lon), Number(point.lat)];
                    }
                    ZHData[point.name] = [{name: '航展馆'}, {name: point.name, car: point.carSum, num: point.seatSum}]
                }
                for(var z in CSDataList){
                    var point = CSDataList[z];
                    // CSData.push([{name: '航展馆'}, {name: point.name, car: point.carSum, num: point.seatSum}]);
                    if(!geoCoordMap[point.name]) {
                        geoCoordMap[point.name] = [Number(point.lon), Number(point.lat)];
                    }
                    CSData[point.name] = [{name: '航展馆'}, {name: point.name, car: point.carSum, num: point.seatSum}]
                }
                for(var z in CCDDataList){
                    var point = CCDDataList[z];
                    // CCDData.push([{name: '航展馆'}, {name: point.name, car: point.carSum, num: point.seatSum}]);
                    if(!geoCoordMap[point.name]) {
                        geoCoordMap[point.name] = [Number(point.lon), Number(point.lat)];
                    }
                    CCDData[point.name] = [{name: '航展馆'}, {name: point.name, car: point.carSum, num: point.seatSum}]
                    // CCDData[point.name][1].car = point.carSum;
                    // CCDData[point.name][1].num = point.seatSum;
                }
            }
        })
    }

    // 获取迁徙图参数
    var getEchartOption = function (val) {
        series = [];
        var dataName,dataData,center,zoom;
        if(val == 1){
            dataName = "全部乘车点";
            dataData = CCDData ;
            center = [113.1201407390885, 22.479444268355664];
            zoom = 24;
        }
        if(val == 2){
            dataName = "市内乘车点";
            dataData = ZHData ;
            center = [113.42278088000789, 22.176600413804227];
            zoom = 103;
        }
        if(val == 3){
            dataName = "直达城市";
            dataData = CSData ;
            center = [113.26798570619934, 22.695395065162064];
            zoom = 22;
        }
        [[dataName, dataData]].forEach(function (item, i) {
            var arr = [];
            for(var a in item[1]){
                arr.push(item[1][a]);
            }
            series.push(
                // 白色线条
                {
                    type: 'lines',
                    zlevel: 1,
                    effect: {
                        show: true,
                        period: 6,
                        trailLength: 0.7,
                        color: '#fff',
                        symbolSize: 3
                    },
                    lineStyle: {
                        normal: {
                            color: color[(val-1)],
                            width: 0,
                            curveness: 0.2
                        }
                    },
                    data: convertData(arr)
                },
                // 移动箭头
                {
                    type: 'lines',
                    zlevel: 2,
                    symbol: ['none', 'arrow'],
                    symbolSize: 10,
                    effect: {
                        show: true,
                        period: 6,
                        trailLength: 0,
                        symbol: planePath,
                        symbolSize: 15
                    },
                    lineStyle: {
                        normal: {
                            color: color[(val-1)],
                            width: 1,
                            opacity: 0.6,
                            curveness: 0.2
                        }
                    },
                    data: convertData(arr)
                },
                {
                    type: 'effectScatter',
                    coordinateSystem: 'geo',
                    zlevel: 2,
                    rippleEffect: {
                        brushType: 'stroke'
                    },
                    label: {
                        normal: {
                            show: true,
                            position: 'right',
                            formatter: '{b}'
                        }
                    },
                    symbolSize: function (val) {
                        return val[2] / 8;
                    },
                    itemStyle: {
                        normal: {
                            color: color[(val-1)],
                        }
                    },
                    data: arr.map(function (dataItem) {
                        var car = dataItem[1].car;
                        if(car == 0) car = 1;
                        return {
                            name: dataItem[1].name,
                            value: geoCoordMap[dataItem[1].name].concat(car)
                        };
                    })
                }
            );
        });
        option = {
            backgroundColor: '#131f36',
            tooltip: {
                trigger: 'item',
                formatter: function (params, ticket, callback) {
                    if (params.seriesType == "lines") {
                        var tipHtml = '<div class="chart-tip"><span>' + params.data.fromName + ' 到 ' + params.data.toName + '</span>'
                                        + '<p>在途车辆：' + params.data.car + ' 辆</p>'
                                        + '<p>运送人数：' + params.data.num + ' 人</p>'
                                        + '</div>';
                        return tipHtml
                    }
                    if (params.seriesType == "effectScatter") {
                        var person = params.data.value[3] ? params.data.value[3] : "0";
                        var tipHtml = '<div class="chart-tip"><span>出发地：' + params.data.name + '</span>'
                                        + '<p>在途车辆：' + params.data.value[2] + ' 辆</p>'
                                        + '<p>运送人数：' + person  + ' 人</p>'
                                        + '</div>';
                        return tipHtml
                    }
                },
                backgroundColor: 'transparent',
                padding: 0
            },
            geo: {
                map: 'china',
                center: center,
                zoom: zoom,
                label: {
                    emphasis: {
                        show: false
                    }
                },
                roam: true,
                itemStyle: {
                    normal: {
                        areaColor: '#2f3a54',
                        borderColor: '#131f36'
                    },
                    emphasis: {
                        areaColor: '#2f3a54'
                    }
                }
            },
            series: series
        };
        return option;
    };

    // 迁徙图自适应浏览器尺寸
    window.onresize = function(){
        if(airDispatch.echartMap != null){
            airDispatch.echartMap.resize();
        }
    };





        /*
        console.log(gps);
        service.createMakers("test2.do");

        var map = new AMap.Map('container', {
            resizeEnable: true, //是否监控地图容器尺寸变化
            mapStyle: "amap://styles/macaron",
            center: [113.58397428, 22.2790923],//中心点坐标
        });
        var trafficLayer = new AMap.TileLayer.Traffic({
            zIndex: 10
        });
        trafficLayer.setMap(map);
        var car_color = ["images/blueCar.png", "images/brownCar.png", "images/chingCar.png", "images/grapeCar.png", "images/grayCar.png", "images/greenCar.png", "images/orangeCar.png", "images/pinkCar.png", "images/redCar.png", "images/whiteCar.png", "images/yellowCar.png"];
        createMarkers();
        var flag = true;
        var sevice = window.setInterval(function () {
            console.log("ajax...");
            $.ajax({
                type: "GET",
                url: "test.do",
                success: function (data) {
                    gps = data.data;
                    updateMarkers();
                }
            });
        }, 10000);
        var titles = {}, contents = {};
        var infoWindow = new AMap.InfoWindow({
            isCustom: true,  //使用自定义窗体
            content: "",
            offset: new AMap.Pixel(16, -45)
        });

        function createMarkers() {
            console.log("init...");
            $.ajax({
                type: "GET",
                url: "test.do",
                success:function (data) {
                    gps = data.data;
                    initMarkers(gps);
                    setTitlesAndContents();
                    console.log("init...success");
                }
            });

        }

        function setTitlesAndContents() {
            for (var g in gps) {
                var id = gps[g].id;
                titles[id] = gps[g].vehicleNo;
                contents[id] = [];
                contents[id].push('<span style="font-size:11px;color:#F00;">司机：AAA</span>');
                contents[id].push('<span style="font-size:11px;color:#F00;">速度：' + gps[g].vec1 + '</span>');
                contents[id].push('<span style="font-size:11px;color:#F00;">方向：' + gps[g].direction + '</span>');
                contents[id].push("from:aaaa  to:bbb");
                contents[id].push("电话：010-64733333");
            }
            console.log("init titles and contents...");
        }

        //构建自定义信息窗体
        function createInfoWindow(title, content) {
            var info = document.createElement("div");
            info.className = "info";

            //可以通过下面的方式修改自定义窗体的宽高
            info.style.width = "180px";
            // 定义顶部标题
            var top = document.createElement("div");
            var titleD = document.createElement("div");
            var closeX = document.createElement("img");
            top.className = "info-top";
            titleD.innerHTML = title;
            closeX.src = "https://webapi.amap.com/images/close2.gif";
            closeX.onclick = closeInfoWindow;

            top.appendChild(titleD);
            top.appendChild(closeX);
            info.appendChild(top);

            // 定义中部内容
            var middle = document.createElement("div");
            middle.className = "info-middle";
            middle.style.backgroundColor = 'white';
            middle.innerHTML = content;
            info.appendChild(middle);

            // 定义底部内容
            var bottom = document.createElement("div");
            bottom.className = "info-bottom";
            bottom.style.position = 'relative';
            bottom.style.top = '0px';
            bottom.style.margin = '0 auto';
            var sharp = document.createElement("img");
            sharp.src = "https://webapi.amap.com/images/sharp.png";
            bottom.appendChild(sharp);
            info.appendChild(bottom);
            return info;
        }
        //关闭信息窗体
        function closeInfoWindow() {
            map.clearInfoWindow();
        }
        function updateMarkers() {
            for (var g in gps) {
                var id = gps[g].id;
                markers[id].setPosition([gps[g].lon, gps[g].lat]);
            };
        }
        function initMarkers(datas) {
            for(var d in datas){
                var color = car_color[0];
                var position = datas[d];
                var marker = new AMap.Marker({
                    position: new AMap.LngLat(position.lon, position.lat),
                    offset: new AMap.Pixel(-10, -10),
                    icon: color,
                    angle: Number(position.direction) + 90,
                    extData:datas[d]
                });
                markers[datas[d].id] = marker;
                map.add(marker);
            }
            for (var m in markers) {
                markers[m].on("click",function (event) {
                    var extData = event.target.Je.extData;
                    infoWindow.setContent(createInfoWindow(titles[extData.id],contents[extData.id].join("<br/>")));
                    infoWindow.open(map, markers[extData.id].getPosition());
                });
            }
            console.log(markers);
        }
        window.unonload = function(){
            window.confirm("单击“确定”离开。单击“取消”终止");
            window.clearInterval(sevice);
        }
    */
